#ifndef PLOT
#define PLOT
#include "stdafx.h"
//using namespace std;
class plot
{
	
	Inp_weather *inp_weather;
	Inp_weather *inp_weather_lon;
	

	inp_measurements *n2o_day;
	inp_measurements *n2o_mon;
	inp_measurements *n2o_year;
	inp_measurements *n2o_EF_site;
	inp_measurements *n2o_EF_plot;


	Inp_croprot *croprot;
	Inp_fertrot *fertrot;
	
	Mod_in *input_grids;
	
	
	// Teilmodelle
	//ETP_Modelle_deklarieren
	Mod_ETP_Turc	*mod_etp, *mod_etp_lon;
	//Snow_Modelle_deklarieren
	Compute_Snow_growth *compute_snow_growth;
	Compute_Snow_melt_Tagesgradverfahren *compute_snow_melt;
	Mod_Snow_simple *mod_snow;
	//	Interception
	Mod_Interception_simple *mod_interception;
	// Surface water
	Mod_Surface_water_simple *mod_surface_water;
	// wc
	Mod_wc_fc *mod_wc;
	// hdraulic properties
	Mod_PDF_Hydraulics_KA5 *mod_pdf;
	//   soilphysics
	Mod_Soilphysics_from_top_layer *mod_soilphysics;
	// cropmodel
	Mod_Crop_epi *mod_crop;
	// Soiltemperaturmodel
	Mod_Soiltemp *mod_soiltemp;
	
	// time discretisation
	tempmap <string,double> *tempgrid_lt;
	tempmap <string,double> *tempgrid;
	string name;
	string root;
	string suffix_inp;
	string suffix_val;
	string suffix_out;

	time_intervall measurement_intervall;
	time_intervall simulation_intervall;

	map < string,map <string,int> > IO_options;
	map <string,int> IO_options_null;

	map<  string,double> plotprops;
        
       // startyear	startmon	startday	endyear	endmon	endday	dur
        //lat	lon	n2o_ann	site_id	plot_id	clay	silt	sand	bd	SOC
        //Ntot	pH	EF_slope	EF_intercept	previous_crop	recent_crop	
        //croptype	recent_Nfert	recent_NO3	recent_NH4	recent_NH2	
        //recent_pig_slurrys_deep_application	recent_cattle_slurrys_deep_application	
        //recent_poultry_slurrys_deep_application	recent_pig_slurrys_surface_applied	
        //recent_cattle_slurrys_surface_applied	recent_poultry_slurrys_surface_applied	
        //recent_pig_solid_manure	recent_cattle_solid_manure	
        //N_9	N_10	N_11	recent_N_mineralization	recent_N_Deposition	
        //recent_N_grazing	N_res1	N_res2	yieldN

        
        
        

	/*int set_croprot_from_croplist2D (list2d *croplist,timestamp firstdate,timestamp lastdate);
	int set_croprot_from_plotprops(list2d *croplist,timestamp firstdate,timestamp lastdate);
	int set_croprot_from_file(timestamp firstdate,timestamp lastdate);*/


	int set_IO_options();
	int read_plotprops_from_list2d(list2d &l,int row,string inroot);
public:
	plot()
	{	;
	}
	plot(list2d &plotprops_list,int row,string inroot){
		croprot=NULL;     IO_options["croprot"]=		IO_options_null;
		fertrot=NULL;     IO_options ["fertrot"]=		IO_options_null;
		n2o_day=NULL;     IO_options ["n2o_day"]=		IO_options_null;
		n2o_mon=NULL;     IO_options ["n2o_mon"]=		IO_options_null;
		n2o_year=NULL;    IO_options ["n2o_year"]=		IO_options_null;
		n2o_EF_site=NULL; IO_options ["n2o_EF_site"]=	IO_options_null;
		n2o_EF_plot=NULL; IO_options ["n2o_EF_plot"]=	IO_options_null;
		inp_weather=NULL;	  IO_options["inp_weather"]=		IO_options_null;
		inp_weather_lon=NULL;  IO_options ["input_weather_lon"]=	IO_options_null;
	
		mod_etp=NULL;	  IO_options ["ETP_mon"]=		IO_options_null;
		set_IO_options();
		suffix_inp=".inp";
		suffix_val=".val";
		//read_plotprops
		read_plotprops_from_list2d( plotprops_list, row, inroot);
		// Define Measuremt Intervall
			timestamp start,end;
			start.set((int)plotprops["startyear"]-1,(int)plotprops["startmon"],
				plotprops["startday"]);
			end.set((int)plotprops["endyear"],
			(int)plotprops["endmon"],plotprops["endday"]);
			measurement_intervall.set(start, end);
		// Define_Simulation Intervall
			simulation_intervall=measurement_intervall;
			simulation_intervall.get_start().set_add_days(-365);
	}
	int set_inputs(list2d *croplist, list2d *fertlist);
	int set_model_environment();
	
	int run()
	{	  
		return 0;
	}
	string get_root();
	       
};
#endif